
#pragma once

#include <memory>
#include "URL.h"

class HttpRequest;
typedef std::shared_ptr<HttpRequest> HttpRequestPtr;

class HttpRequest
{
public:
	static HttpRequestPtr NewHttpRequest(const std::string& method, 
		const std::string& url, const std::string& body);

	URL& url(){
		return url_;
	}
	const URL& url() const{
		return url_;
	}
	std::map<std::string, std::string>& header(){
		return header_;
	}
	const std::map<std::string, std::string>& header() const{
		return header_;
	}
	std::string& method(){
		return method_;
	}
	const std::string& method() const{
		return method_;
	}
	std::string& body(){
		return body_;
	}
	const std::string& body() const {
		return body_;
	}
private:
	URL			url_;
	std::map<std::string, std::string> header_;
	std::string method_;
	std::string body_;
};

inline HttpRequestPtr HttpRequest::NewHttpRequest(const std::string& method,
	const std::string& url, const std::string& body)
{
	HttpRequestPtr req = std::make_shared<HttpRequest>();
	req->url().parse(url);
	req->body() = body;
	req->method() = method;

	return req;
}
